package com.zl.Sqlite;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * User: c3t
 * Date: 14-5-1
 * Time: 下午3:44
 */
public class DBheloper extends SQLiteOpenHelper {
    private final static String DB_NAME = "test2.db";
    private final static int VERSION = 1;
    private final static String TABLE_NAME="user";
    private static DBheloper instance = null;

    private DBheloper(Context context) {
        super(context, DB_NAME, null, VERSION);
    }

    public static DBheloper getInstance(Context context) {
        if (null == instance) {
            synchronized (DBheloper.class) {
                if (null == instance) {
                    instance = new DBheloper(context);
                }
            }
        }
        return instance;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        StringBuilder sb = new StringBuilder();
        sb.append("create table ");
        sb.append(TABLE_NAME);
        sb.append(" ( id integer primary key autoincrement,name varchar(10))");
        db.execSQL(sb.toString());
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    }
}
